from a2a.server.agent_execution import AgentExecutor, RequestContext
from a2a.server.events import EventQueue
from a2a.utils import new_agent_text_message

from AIAgent智能体与MCP开发实战.第8章多智能体写作的原生.HelloworldAgent import HelloWorldAgent


class HelloWorldExecutor(AgentExecutor):
    def __init__(self):
        self.agent = HelloWorldAgent()


    async def execute(self,context:RequestContext,event_queue:EventQueue) -> None:
        result = self.agent.say_hello()
        await event_queue.dequeue_event(new_agent_text_message(result))
